﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using ReflectionStudio.Core.Events;

namespace WPFExcelReport
{
    public partial class INTEXAV95Data
    {
        public DataSet InsertAB50ABPOS(DataRow dwGAAUF, string ABKAUFART, string KRS, int LeadTime, string apKRS, string apNum, string abplo, string abplb, string abplp)
        {
            #region============VARIABLE====================
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataSet setTemp = new DataSet();
            DataRow dwAPZUORD = null;
            DataRow dwLocal = null, dwGSDAT=null;
            DataTable tableLocal = null;
            OracleCommand or1;
            string LFD = "000000", POS = "010";
            string ABPART = "", ABPVAR = "", WDPRART = "", WDPRVAR = "";
            string ABPSME = "2"; 
            string ABPNEUBEN = "SUNLV   ";
            string ABPNEUDAT = "20110823", STARTDATE = "20110822", ENDDATE = "20110826";
            string APZALFDNR = " ", APZANRKRS = " ";
            #endregion
            try
            {
                or1 = OracleDB.CreateCommand();
                #region============GETNUMBER====================== 
                ABPART = dwGAAUF["GAART"].ToString();
                ABPVAR = dwGAAUF["GAVAR"].ToString();
                setResult =QueryGSDAT(ABPART, ABPVAR);
                if (setResult.Tables.Count > 0)
                {
                    if (setResult.Tables[0].Rows.Count > 0)
                    {
                        dwGSDAT = setResult.Tables[0].Rows[0];
                    }
                }
                if (dwGSDAT == null)
                    return setReturn;
                if (dwGSDAT["GSFERTKZ"].ToString() != "E"
                    &dwGSDAT["GSFERTKZ"].ToString() != "F"
                    & dwGSDAT["GSFERTKZ"].ToString() != "X"
                    )
                    return setReturn;
                APZANRKRS = apKRS;
                APZALFDNR = apNum;               
                #endregion
                LFD = GetAUFLFD(KRS);
                #region============MAPDATA=========================
                dwLocal = SetData.ABPOS.NewRow();
                ABPNEUBEN = UserID;
                ABPNEUDAT = iDate;
                ENDDATE = dwGAAUF["GADATVON"].ToString();
                STARTDATE = GetDateAddDays(ENDDATE, 0 - LeadTime);
                dwLocal["ABPMANDANT"] = dwGAAUF["GAMANDANT"];
                dwLocal["ABPAUFKRS"] = KRS;
                dwLocal["ABPAUFLFD"] = LFD;
                dwLocal["ABPAUFPOS"] = POS;
                dwLocal["ABPAUFART"] = ABKAUFART;
                dwLocal["ABPNEUBEN"] = ABPNEUBEN;
                dwLocal["ABPNEUDAT"] = ABPNEUDAT;
                dwLocal["ABPART"] = ABPART;
                dwLocal["ABPVAR"] = ABPVAR;
                dwLocal["ABPWAKZ"] = "G";
                dwLocal["ABPFARBE"] = dwGAAUF["GAFARBE"].ToString();

                dwLocal["ABPLAEAENDA"] = 0;
                dwLocal["ABPSTDLAE"] = 0;
                ABPSME = "1";
                dwLocal["ABPSME"] = ABPSME;
                dwLocal["ABPENDDATA"] = ENDDATE;
                dwLocal["ABPLIEFDAT"] = ENDDATE;
                dwLocal["ABPENDDAT"] = ENDDATE;
                dwLocal["ABPLIEFDATN"] = ENDDATE;
                dwLocal["ABPENDDATA"] = ENDDATE;

                dwLocal["ABPSTARTDAT"] = STARTDATE;
                dwLocal["ABPSTARTDATA"] = STARTDATE;
                dwLocal["ABPVTDATE"] = iDate;
                dwLocal["ABPTERMDAT"] = ENDDATE;
                dwLocal["ABPSTARTDATN"] = STARTDATE;

                dwLocal["ABPANRKR"] = APZANRKRS;
                dwLocal["ABPALFDNR"] = APZALFDNR;


                ABPSOLLMENGE1 = "0";
                ABPSOLLMENGE2 = "0";
                ABPSOLLMENGE3 = "0";
                ABPSOLLMENGE4 = "0";
                ABPSOLLMENGE5 = System.Math.Round(System.Convert.ToDouble(dwGAAUF["GAKG1"].ToString()), 0).ToString();
                ABPSOLLMENGE6 = "0";
                ABPSOLLMENGE7 = "0";
                ABPSOLLMENGE8 = "0";
                dwLocal["ABPSOLLMENGE1"] = ABPSOLLMENGE1;
                dwLocal["ABPSOLLMENGE2"] = ABPSOLLMENGE2;
                dwLocal["ABPSOLLMENGE3"] = ABPSOLLMENGE3;
                dwLocal["ABPSOLLMENGE4"] = ABPSOLLMENGE4;
                dwLocal["ABPSOLLMENGE5"] = ABPSOLLMENGE5;
                dwLocal["ABPSOLLMENGE6"] = ABPSOLLMENGE6;
                dwLocal["ABPSOLLMENGE7"] = ABPSOLLMENGE7;
                dwLocal["ABPSOLLMENGE8"] = ABPSOLLMENGE8;

                dwLocal["ABPAENDBEN"] = ABPNEUBEN;
                dwLocal["ABPAENDDAT"] = ABPNEUDAT;
                dwLocal["ABPZLO"] = abplo;
                dwLocal["ABPZLB"] =abplb;
                dwLocal["ABPBLO"] = abplo;
                dwLocal["ABPAESTAT"] = " ";
                dwLocal["ABPDIVARTKZ"] = "N";
                dwLocal["ABPVERSAEND"] = "M";
                
                #endregion

                #region============INSERT==========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO ABPOS(ABPMANDANT, ABPAUFKRS, ABPAUFLFD, ABPAUFPOS, ABPVFAUFKRS, ABPVFAUFLFD, ABPVFAUFPOS, ABPAUFART, ABPAUFST, ABPAUFSTV, ABPAUFSTB, ABPAUTO, ABPPRIO, ABPTLVF, ABPDIVARTKZ, ABPKUNDNR, ABPWERK, ABPABT, ABPWAKZ, ABPART, ABPVAR, ABPFARBE, ABPDESS, ABPCOLORIT, ABPBESCHICH, ABPGROE, ABPAUFM, ABPVERP, ABPANZVP, ABPFWARTGRA, ABPFWARTGRP, ABPZLO, ABPZLB, ABPBLO, ABPSME, ABPSOLLMENGE1, ABPSOLLMENGE2, ABPSOLLMENGE3, ABPSOLLMENGE4, ABPSOLLMENGE5, ABPSOLLMENGE6, ABPSOLLMENGE7, ABPSOLLMENGE8, ABPRESMGE, ABPRESKG, ABPRESSTK, ABPZUGET, ABPZUGKG, ABPZUGSTK, ABPDILFM, ABPDIKG, ABPDISTK, ABPZTLGKOMP, ABPSMGKZZU, ABPVLLFM, ABPVLKG, ABPVLSTK, ABPEALFM, ABPEAKG, ABPEASTK, ABPEBLFM, ABPEBKG, ABPEBSTK, ABPABLFM, ABPABKG, ABPABSTK, ABPVSLFM, ABPVSKG, ABPVSSTK, ABPRTLFM, ABPRTKG, ABPRTSTK, ABPROHWDAT, ABPKDDAT, ABPWVDAT, ABPLIEFDAT, ABPLRUECK, ABPLRDATE, ABPDLR, ABPVTRUECK, ABPVTDATE, ABPUNKLAR, ABPVERSDAT, ABPFREIDAT, ABPSTARTDAT, ABPENDDAT, ABPSTARTDATA, ABPENDDATA, ABPLTERMAK, ABPBESTDAT, ABPANRKR, ABPALFDNR, ABPAFOLGEV, ABPAFOLGEB, ABPANRKR2, ABPALFDNR2, ABPAFOLGEV2, ABPAFOLGEB2, ABPANRKR3, ABPALFDNR3, ABPAFOLGEV3, ABPAFOLGEB3, ABPANRKR4, ABPALFDNR4, ABPAFOLGEV4, ABPAFOLGEB4, ABPVERSAEND, ABPVERSZL, ABPTLFREIG, ABPTLFMG, ABPFREIGKZ, ABPLMAFOLGE, ABPENDAUFM, ABPZAUFM, ABPLIEFNR, ABPGESSTA, ABPKDSTA, ABPWSSTA, ABPAPSTA, ABPRZSTA, ABPWPSTA, ABPWBSTA, ABPABSTA, ABPERLKZ, ABPERLDAT, ABPBEWKZ, ABPDRKZ1, ABPDRKZ2, ABPDRKZ3, ABPDRKZ4, ABPDRKZ5, ABPDRKZ6, ABPDRKZ7, ABPDRKZ8, ABPDRKZ9, ABPDRKZ10, ABPDR1USER, ABPDR1DAT, ABPDR8USER, ABPDR8DAT, ABPRETOURZL, ABPRPCOUNTAK, ABPURAUFKRS, ABPURAUFLFD, ABPURAUFPOS, ABPASAUFKRS, ABPASAUFLFD, ABPASAUFPOS, ABPREAFOLGE, ABPRWKRS, ABPRWLFD, ABPSTKNRKR, ABPSERIE, ABPAGBKZ, ABPWAART, ABPANZSTK, ABPZUGETGES, ABPSTKKZ, ABPSTKLG, ABPANZSTKR, ABPABZKZ, ABPBDEKZ, ABPSUBSYS, ABPDATBDE, ABPUHRBDE, ABPDISPOKZ, ABPSCHLICHTE, ABPZZUSATZ, ABPZZUSKZ, ABPSZUSTAND, ABPIZUSTAND, ABPSZUSATZKZ1, ABPSZUSATZKZ2, ABPSZUSATZKZ3, ABPSZUSATZKZ4, ABPWERKE, ABPLBMUSTR, ABPFBMUSTR, ABPREAUFKRS, ABPREAUFLFD, ABPREAUFPOS, ABPLTVORL, ABPFDZ, ABPARTEX, ABPLETEILNR, ABPANSNR, ABPUPOS, ABPTP, ABPLBDENR, ABPTMCOUNT, ABPTMCOUNTAK, ABPKDPARTIE, ABPBAHNKZ, ABPGAENGE, ABPZWTWAHL, ABPDIVWLFM, ABPDIVWKG, ABPDISPOST, ABPKETTAUFT, ABPKETTGARN, ABPSPGRD, ABPSPBENID, ABPSPDAT, ABPLMDAT, ABPLMZT, ABPWPLKZ, ABPKKUNDNR, ABPKLAND, ABPKVB, ABPKVG, ABPKPROGRP, ABPKARTGRP, ABPKVKZ, ABPLAEVON, ABPLAEBIS, ABPSTDLAE, ABPMGV, ABPMGB, ABPPAS, ABPPAI, ABPAZUTEIL, ABPZUTART, ABPFA, ABPGA, ABPQA, ABPMAFZST, ABPQPKTH, ABPQPKTLH, ABPSTKNEUTR, ABPREGEL, ABPSTAFFNR, ABPWERKEKZ, ABPWKSTKRS, ABPWKST, ABPWKART, ABPWMNRKRS, ABPWMLFDNR, ABPWMPOS, ABPWMODNR, ABPWINTV, ABPWKENN, ABPWSTOERGRD, ABPWAKSTKRS, ABPWAKST, ABPWPERSNR, ABPWDATV, ABPWZEITV, ABPWDATB, ABPWZEITB, ABPWSTA, ABPFKALK, ABPLIEFDATN, ABPLAEAENDE, ABPLAEAENDA, ABPDMWAKZ, ABPDMART, ABPDMVAR, ABPDMDESS, ABPDMCOLORIT, ABPDMFARBE, ABPDMBESCHICH, ABPDKART, ABPDKVAR, ABPDKFARBE, ABPDKBRUT, ABPGENEHMKZ, ABPSTUEART, ABPCOMPKZ, ABPPOSTYP, ABPORDER, ABPNPGRUND, ABPREWEIL, ABPFSCHL, ABPKSTKRS, ABPKST, ABPMURW, ABPMUVB, ABPMUFW, ABPMUPF, ABPERSTFB, ABPERSTDR, ABPERSTBE, ABPMUCTOD, ABPKDFREI, ABPREZFB, ABPREZDR, ABPPRUEF, ABPNIXWE, ABPCOLSTA, ABPFBSTA, ABPBAHNNR, ABPBAHNBRT, ABPFLBEDECK, ABPDATABDE, ABPUHRABDE, ABPLOEKZ, ABPTERMDAT, ABPPRFI, ABPPRVAR, ABPPRBE, ABPPRZU, ABPPRDESS, ABPZUSATZ1, ABPZUSATZ2, ABPZUSATZ3, ABPZUSATZ4, ABPZUSATZ5, ABPFLAG1, ABPFLAG2, ABPFLAG3, ABPFLAG4, ABPFLAG5, ABPORGMG, ABPDIFFMG, ABPRARTKZ, ABPSTARTDATN, ABPAESTAT, ABPLBAUFKRS, ABPLBAUFLFD, ABPLBAUFPOS, ABPVEAUFTRAG, ABPREGBLOG, ABPREGBDATE, ABPPROJNR, ABPSHADE, ABPSHADEUNCL, ABPLICHTART, ABPLINE, ABPFILLER1, ABPAENDZL, ABPAENDBEN, ABPAENDDAT, ABPNEUBEN, ABPNEUDAT)"
                + "VALUES (:ABPMANDANT, :ABPAUFKRS, :ABPAUFLFD, :ABPAUFPOS, '  ', '000000', '000',:ABPAUFART, ' ', '0', '0', ' ', '00', '   ', ' ', '00000000', '   ', '   '"
                + ", 'K', '                    ', '   ', '          ', '          ', '          ', '          ', '       ', '  ', '   ', 0, '     ', '  ', '  ', '  ', '  ', '1', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0"
                + ", 0, 0, 0, '  ', 0, 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, '  ', '      ', '000', '000', '  ', '000000', 0, 0, '  ', '000000', 0, 0, '  ', '000000', 0, 0, ' ', '006', '000', 0, ' ', '000', '  ', '  ', '        ', 'TE', '10'"
                + ", '20', '30', '40', '50', '60', '70', ' ', 0, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '        ', '00000000', '        ', '00000000', 0, 0, '  ', '000000', '000', '  ', '000000', '000', '000', '  ', '000000'"
                + ", '  ', '  ', ' ', '   ', 0, 0, ' ', 0, 0, ' ', 'N', '  ', 0, 0, ' ', '     ', '          ', ' ', '    ', '    ', ' ', ' ', ' ', ' ', ' ', '   ', '   ', '  ', '000000', '000', '               ', 0, '                                                            '"
                + ", 0, 0, 0, 0, 0, 1, 0, '          ', ' ', 0, 0, 0, 0, ' ', ' ', ' ', '  ', '        ', 0, 0, 0, ' ', '        ', '   ', '   ', '   ', '   ', '   ', ' ', 0, 0, 0, 0, 0, 0, 0, ' ', ' ', 0, 0, 0, 0, 0, 0, ' ', '00000000', '00', ' ', '  ', '0000'"
                + ", '000000', '  ', '0000', '00', '000', '00', '  ', '               ', '  ', '0000', '        ', 0, 0, 0, 0, '  ', ' ', 0, 0, 0, ' ', '                    ', '  ', '          ', '          ', '          ', '          ', '                    '"
                + ", '  ', '  ', 0, ' ', '   ', ' ', '   ', '    ', '   ', '  ', '   ', '  ', '0000', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', 0, 0, '00000000', '000000', ' ', '        ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0"
                + ", 0, 0, 0, 0, 0, 0, ' ', '        ', ' ', '  ', '000000', '000', '               ', 0, 0, '                        ', '   ', ' ', '     ', '   ', '                                                                                                      '"
                + ", 1, '        ', 0,:ABPNEUBEN, :ABPNEUDAT)";
                or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwLocal["ABPMANDANT"];
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwLocal["ABPAUFKRS"];
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwLocal["ABPAUFLFD"];
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwLocal["ABPAUFPOS"];
                or1.Parameters.Add("ABPAUFART", OracleType.NVarChar).Value = dwLocal["ABPAUFART"];
                or1.Parameters.Add("ABPNEUBEN", OracleType.NVarChar).Value = dwLocal["ABPNEUBEN"];
                or1.Parameters.Add("ABPNEUDAT", OracleType.NVarChar).Value = dwLocal["ABPNEUDAT"];
                setResult = Connect2Proxy(or1);

                #endregion

                #region============UPDATE=========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE ABPOS SET "
                    + " ABPWAKZ=:ABPWAKZ,ABPART=:ABPART,ABPVAR=:ABPVAR,ABPFARBE=:ABPFARBE"
                    + " ,ABPDIVARTKZ=:ABPDIVARTKZ,ABPVERSAEND=:ABPVERSAEND,ABPSME=:ABPSME,ABPSOLLMENGE1=:ABPSOLLMENGE1,ABPSOLLMENGE2=:ABPSOLLMENGE2,ABPSOLLMENGE3=:ABPSOLLMENGE3"
                    + ",ABPSOLLMENGE4=:ABPSOLLMENGE4,ABPSOLLMENGE5=:ABPSOLLMENGE5,ABPSOLLMENGE6=:ABPSOLLMENGE6,ABPSOLLMENGE7=:ABPSOLLMENGE7"
                    + ",ABPSOLLMENGE8=:ABPSOLLMENGE8"
                    + ",ABPSTDLAE=:ABPSTDLAE,ABPLAEAENDA=:ABPLAEAENDA"
                    + ",ABPENDDAT=:ABPENDDAT,ABPENDDATA=:ABPENDDATA,ABPLIEFDAT=:ABPLIEFDAT,ABPLIEFDATN=:ABPLIEFDATN,ABPSTARTDAT=:ABPSTARTDAT,ABPSTARTDATA=:ABPSTARTDATA,ABPVTDATE=:ABPVTDATE,ABPTERMDAT=:ABPTERMDAT"
                    + ",ABPSTARTDATN=:ABPSTARTDATN"
                    + ",ABPZLO=:ABPZLO,ABPZLB=:ABPZLB,ABPBLO=:ABPBLO,ABPAESTAT=:ABPAESTAT"
                    + " ,ABPANRKR=:ABPANRKR, ABPALFDNR=:ABPALFDNR"
                    + ",ABPAENDBEN=:ABPAENDBEN,ABPAENDDAT=:ABPAENDDAT,ABPAUFART=:ABPAUFART"
                    + " WHERE ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD=:ABPAUFLFD AND ABPAUFPOS=:ABPAUFPOS";

                or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwLocal["ABPMANDANT"];
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwLocal["ABPAUFKRS"];
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwLocal["ABPAUFLFD"];
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwLocal["ABPAUFPOS"];

                or1.Parameters.Add("ABPWAKZ", OracleType.NVarChar).Value = dwLocal["ABPWAKZ"];
                or1.Parameters.Add("ABPART", OracleType.NVarChar).Value = dwLocal["ABPART"];
                or1.Parameters.Add("ABPVAR", OracleType.NVarChar).Value = dwLocal["ABPVAR"];
                or1.Parameters.Add("ABPFARBE", OracleType.NVarChar).Value = dwLocal["ABPFARBE"];

                or1.Parameters.Add("ABPDIVARTKZ", OracleType.NVarChar).Value = dwLocal["ABPDIVARTKZ"];
                or1.Parameters.Add("ABPVERSAEND", OracleType.NVarChar).Value = dwLocal["ABPVERSAEND"];
                
                    or1.Parameters.Add("ABPSME", OracleType.NVarChar).Value = dwLocal["ABPSME"];
                or1.Parameters.Add("ABPSOLLMENGE1", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE1"];
                or1.Parameters.Add("ABPSOLLMENGE2", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE2"];
                or1.Parameters.Add("ABPSOLLMENGE3", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE3"];
                or1.Parameters.Add("ABPSOLLMENGE4", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE4"];
                or1.Parameters.Add("ABPSOLLMENGE5", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE5"];
                or1.Parameters.Add("ABPSOLLMENGE6", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE6"];
                or1.Parameters.Add("ABPSOLLMENGE7", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE7"];
                or1.Parameters.Add("ABPSOLLMENGE8", OracleType.NVarChar).Value = dwLocal["ABPSOLLMENGE8"];

                or1.Parameters.Add("ABPSTDLAE", OracleType.NVarChar).Value = dwLocal["ABPSTDLAE"];
                or1.Parameters.Add("ABPLAEAENDA", OracleType.NVarChar).Value = dwLocal["ABPLAEAENDA"];

                or1.Parameters.Add("ABPENDDAT", OracleType.NVarChar).Value = dwLocal["ABPENDDAT"];
                or1.Parameters.Add("ABPENDDATA", OracleType.NVarChar).Value = dwLocal["ABPENDDATA"];
                or1.Parameters.Add("ABPLIEFDAT", OracleType.NVarChar).Value = dwLocal["ABPLIEFDAT"];
                or1.Parameters.Add("ABPLIEFDATN", OracleType.NVarChar).Value = dwLocal["ABPLIEFDATN"];
                or1.Parameters.Add("ABPSTARTDAT", OracleType.NVarChar).Value = dwLocal["ABPSTARTDAT"];
                or1.Parameters.Add("ABPSTARTDATA", OracleType.NVarChar).Value = dwLocal["ABPSTARTDATA"];
                or1.Parameters.Add("ABPVTDATE", OracleType.NVarChar).Value = dwLocal["ABPVTDATE"];
                or1.Parameters.Add("ABPTERMDAT", OracleType.NVarChar).Value = dwLocal["ABPTERMDAT"];
                or1.Parameters.Add("ABPSTARTDATN", OracleType.NVarChar).Value = dwLocal["ABPSTARTDATN"];
                or1.Parameters.Add("ABPZLO", OracleType.NVarChar).Value = dwLocal["ABPZLO"];
                or1.Parameters.Add("ABPZLB", OracleType.NVarChar).Value = dwLocal["ABPZLB"];
                or1.Parameters.Add("ABPBLO", OracleType.NVarChar).Value = dwLocal["ABPBLO"];
                or1.Parameters.Add("ABPAESTAT", OracleType.NVarChar).Value = dwLocal["ABPAESTAT"];

                or1.Parameters.Add("ABPANRKR", OracleType.NVarChar).Value = dwLocal["ABPANRKR"];
                or1.Parameters.Add("ABPALFDNR", OracleType.NVarChar).Value = dwLocal["ABPALFDNR"];

                or1.Parameters.Add("ABPAUFART", OracleType.NVarChar).Value = dwLocal["ABPAUFART"];
                or1.Parameters.Add("ABPAENDBEN", OracleType.NVarChar).Value = dwLocal["ABPAENDBEN"];
                or1.Parameters.Add("ABPAENDDAT", OracleType.NVarChar).Value = dwLocal["ABPAENDDAT"];
                setResult = Connect2Proxy(or1);
                #endregion

                #region============SELECT==========================
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT * FROM ABPOS "
                + " WHERE ABPMANDANT=:ABPMANDANT AND ABPAUFKRS=:ABPAUFKRS AND ABPAUFLFD= :ABPAUFLFD AND ABPAUFPOS= :ABPAUFPOS";

                or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwLocal["ABPMANDANT"];
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwLocal["ABPAUFKRS"];
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwLocal["ABPAUFLFD"];
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwLocal["ABPAUFPOS"];
                setResult = Connect2Proxy(or1);
                if (setResult.Tables.Count > 0)
                {
                    setResult.Tables[0].TableName = "ABPOS";
                }
                setReturn.Merge(setResult);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public void UpdateGAAUF(DataRow dwGAAUF)
        {
            try
            {
                OracleCommand or1 = new OracleCommand();
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE GAAUF SET GAKG2=:GAKG2 " 
                     + " WHERE GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD AND GAAUFPOS=:GAAUFPOS AND GAPOS=:GAPOS";
                or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwGAAUF["GAMANDANT"];
                or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwGAAUF["GAAUFKRS"];
                or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwGAAUF["GAAUFLFD"];
                or1.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwGAAUF["GAAUFPOS"];
                or1.Parameters.Add("GAPOS", OracleType.NVarChar).Value = dwGAAUF["GAPOS"];
                or1.Parameters.Add("GAKG2", OracleType.NVarChar).Value = dwGAAUF["GAKG1"];
                Connect2Proxy(or1);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public DataSet InsertAB50ABAUFM(DataRow dwAB50, DataRow dwGAAUF)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            OracleCommand or1;
            DataRow dwLocal;
            DataRow dwBSGROE = null;
            try
            {
                //将对应的需求的GAKG2更新
                UpdateGAAUF(dwGAAUF);  
                #region============MAPDATA=========================
                dwLocal = SetData.ABAUFM.NewABAUFMRow();
                dwLocal["ABAMANDANT"] = dwAB50["ABPMANDANT"];
                dwLocal["ABAAUFTYP"] = "V";
                dwLocal["ABAAUFKRS"] = dwAB50["ABPAUFKRS"];
                dwLocal["ABAAUFLFD"] = dwAB50["ABPAUFLFD"];
                dwLocal["ABAAUFPOS"] = dwAB50["ABPAUFPOS"];
                dwLocal["ABANEUBEN"] = dwAB50["ABPNEUBEN"];
                dwLocal["ABANEUDAT"] = dwAB50["ABPNEUDAT"];

                string ABPSME = dwAB50["ABPSME"].ToString();
                long ABASGESLG = 0;
                string ABALEAPOS = "2", ABASME = "2";
                ABASME = ABPSME;  
                dwLocal["ABASANZSTK"] = 0;
                dwLocal["ABASSTKLG"] = 0;
                dwLocal["ABASSTKLGV"] =0;
                dwLocal["ABASSTKLGB"] = 0;
                dwLocal["ABASGESGEW"] = dwAB50["ABPSOLLMENGE5"].ToString();
                dwLocal["ABASME"] = ABPSME;
                dwLocal["ABALEAPOS"] = ABALEAPOS;
                #endregion

                #region============INSERT0001====================== 
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO ABAUFM(ABAMANDANT, ABAAUFTYP, ABAAUFKRS, ABAAUFLFD, ABAAUFPOS, ABAAPOS, ABAERLKZ, ABARESMG, ABASANZSTK, ABASSTKLG, ABASSTKLGV, ABASSTKLGB, ABASSTKGEW, ABASSTKGEWV, ABASSTKGEWB, ABASSTKBRT, ABASSTKBRTV, ABASSTKBRTB, ABAIANZSTK, ABAIZENSUR1, ABAIZENSURKZ1, ABAIZENSUR2, ABAIZENSURKZ2, ABAIGESLGZS1, ABAIGESLGZS2, ABASTDPOS, ABASFERTKZ, ABAUEBKZ, ABAUMAILKZ, ABASGESLG, ABASGESGEW, ABASME, ABAFRMG, ABARSTSLG, ABARSTSGEW, ABAMINUSLG, ABAMINUSGEW, ABALEAPOS, ABAPOOL, ABARESFLAG, ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS, ABAVKUPOS, ABAVB, ABAVG, ABAZUPRIO, ABASTKNEUTR, ABARESPROG, ABARESBEN, ABARESDAT, ABARESZEIT, ABARVSACHB, ABARKUNDNR, ABARBISDAT, ABAVLVB, ABAVLVG, ABAVLSACHB, ABAVLGEGEN, ABAPRKUNDNR, ABAPRAUFKRS, ABAPRAUFLFD, ABAPRAUFPOS, ABAGENEHM, ABAGSACHB, ABALIEFNR, ABAVSACHB, ABAVSTKNR, ABAVERSWEG, ABAMVERSDAT, ABAWVDAT, ABGENDAT, ABAGENNR, ABAGENNAME, ABAGENWEG, ABAZUSTK, ABAZULG, ABAOPTKZ, ABAMAFZST, ABAPART1, ABAPARTST1, ABAPART2, ABAPARTST2, ABAPART3, ABAPARTST3, ABAPART4, ABAPARTST4, ABAPART5, ABAPARTST5, ABAPART6, ABAPARTST6, ABAPART7, ABAPARTST7, ABAPART8, ABAPARTST8, ABAPART9, ABAPARTST9, ABAPART10, ABAPARTST10, ABASZENSUR, ABASZENSURKZ, ABAKUTLSTK, ABABAHNKZ, ABAWDUPOS, ABABAHNEN, ABATEILKZ, ABAKUNDNRU, ABAWERKU, ABAABTU, ABAARTU, ABAVARU, ABADESSU, ABACOLORITU, ABAFARBEU, ABABESCHU, ABAFARBBEZU, ABAANZ1, ABALAENGE1, ABABREITE1, ABAANZ2, ABALAENGE2, ABABREITE2, ABAANZ3, ABALAENGE3, ABABREITE3, ABAANZ4, ABALAENGE4, ABABREITE4, ABAANZ5, ABALAENGE5, ABABREITE5, ABAVERSDAT, ABAVATYP, ABAANZORG, ABAANZKOP, ABAVERSART, ABASPED, ABALIEFKD, ABAVERSKD, ABAADRSLL, ABAVAKZ, ABALIEFKOMP, ABATEILNR, ABAVDPKZ, ABATPMA, ABABOXMAX, ABABOXANZ, ABALGEBNR, ABANKGEB, ABAIFEUCHTE, ABAKUNDNR, ABASTKNR, ABAPARTIE, ABAPARTIEKZ, ABAKDPARTIE, ABAKDAUFTNR, ABAKDAUFDAT, ABAMAART, ABASTKLFDNR, ABAAUFMSL, ABAZUSAM, ABAPACKTYP, ABATAX, ABAHUELSE, ABAWOBST, ABAWICKL, ABAFDRES, ABAKF, ABANRVERG, ABASTKNRKRS, ABASUFFART, ABATRENNZ, ABALAENGEU, ABALAENGES, ABASCHRITW, ABAFUELLZ, ABAASSCHNIT, ABAETITYP, ABAANZRET, ABAKDETKZ, ABADOPPEL, ABALOAN, ABALBAN, ABALPAN, ABAAUFBKZAN, ABALOA2, ABALBA2, ABALPA2, ABAABKZA2, ABAPKL, ABABEM1, ABABEM2, ABAMRKM1, ABAMRKM2, ABAMRKM3, ABAKZNTO, ABAFESP, ABADIAUFKRS, ABADIAUFLFD, ABADIAUFPOS, ABADILG, ABADIGEW, ABADISTK, ABADISLG, ABADISGEW, ABABA, ABAASGESLG, ABAASGESGEW, ABAPNRKRS, ABAPLFDNR, ABAGKREGEL, ABAPROVOR, ABAPRSFE, ABAWSCHTXT, ABAVORSGEL, ABASELVL, ABASELVR, ABAKOLL, ABAVKART, ABAVKFARBE, ABAGBEDKZ, ABADL, ABAKDPARTKZ, ABAFILLER, ABAAENDZL, ABAAENDBEN, ABAAENDDAT, ABANEUBEN, ABANEUDAT)"
                    + "VALUES (:ABAMANDANT, :ABAAUFTYP, :ABAAUFKRS, :ABAAUFLFD, :ABAAUFPOS, '0001', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0, 0, 1, ' ', ' ', ' '"
                + ", 0, 0, ' ', 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', '  ', '000000', '000', '00', '   ', '   ', '9', ' ', '        ', '        ', 0, 0, '        ', '        ', 0, '   ', '   ', '        ', ' ', '        ', '  ', '000000', '000', ' ', '        ', '        ', '        ', '            ', '  ', 0, 0, 0, '            ', '                              ', '  ', 0, 0, ' ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, ' ', ' ', 0, ' ', 1, 0, ' ', '        ', '   ', '   ', '                    ', '   ', '          ', '          ', '          ', '          ', '                    ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '  ', 0, 0, '   ', '   ', '        ', '        ', '        ', 'J', ' ', 0, ' ', '    ', 0, 0, '        ', '  ', 0, '00000000', '            ', '0000000', ' ', '          ', '                    ', 0, ' ', 0, '  ', '  ', '    ', '   ', '      ', ' ', ' ', ' ', ' ', ' ', '  ', ' ', ' ', 0, 0, 0, ' ', 'N', '  ', 0, ' ', '          ', '  ', '  ', '        ', ' ', '  ', '  ', '        ', ' ', '  ', '                                                            ', '                                                            ', '    ', '    ', '    ', ' ', ' ', '  ', '000000', '000', 0, 0, 0, 0, 0, '      ', 0, 0, '  ', '000000', '00000000', '        ', 0, '   ', ' ', 0, 0, '     ', '                        ', '          ', ' ', ' ', ' ', '                                                                                    ', 1, '        ', 0"
                + ", :ABANEUBEN, :ABANEUDAT)";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABANEUBEN", OracleType.NVarChar).Value = dwLocal["ABANEUBEN"];
                or1.Parameters.Add("ABANEUDAT", OracleType.NVarChar).Value = dwLocal["ABANEUDAT"];
                setResult = Connect2Proxy(or1);
                #region============UPDATE0001======================
                or1 = OracleDB.CreateCommand();
                dwLocal["ABAAPOS"] = "0001";
                or1.CommandText = "UPDATE ABAUFM SET "
                    + "ABASGESGEW=:ABASGESGEW,ABASME=:ABASME,ABALEAPOS=:ABALEAPOS "
                    + " WHERE ABAMANDANT=:ABAMANDANT AND ABAAUFTYP=:ABAAUFTYP AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD"
                +" AND ABAAUFPOS=:ABAAUFPOS AND ABAAPOS=:ABAAPOS";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABAAPOS", OracleType.NVarChar).Value = dwLocal["ABAAPOS"];
                 
                or1.Parameters.Add("ABASGESGEW", OracleType.NVarChar).Value = dwLocal["ABASGESGEW"];
                or1.Parameters.Add("ABASME", OracleType.NVarChar).Value = dwLocal["ABASME"];
                or1.Parameters.Add("ABALEAPOS", OracleType.NVarChar).Value = dwLocal["ABALEAPOS"];

                setResult = Connect2Proxy(or1);
                #endregion
                #endregion

                #region============INSERT0002======================
                string qty = System.Math.Round(System.Convert.ToDouble(dwGAAUF["GAKG1"].ToString()) * 10, 0).ToString();
                dwLocal["ABASANZSTK"] = "1";
                dwLocal["ABAAPOS"] = "0002";
                dwLocal["ABAVKAUFTYP"] = "V";
                dwLocal["ABAVKAUFKRS"] = dwGAAUF["GAAUFKRS"];
                dwLocal["ABAVKAUFLFD"] = dwGAAUF["GAAUFLFD"];
                dwLocal["ABAVKAUFPOS"] = dwGAAUF["GAAUFPOS"];
                dwLocal["ABAVKUPOS"] = dwGAAUF["GAPOS"];
                dwLocal["ABAPRAUFKRS"] = "  ";
                dwLocal["ABAPRAUFLFD"] = "000000";
                dwLocal["ABAPRAUFPOS"] = "000";
                dwLocal["ABAVERSDAT"] = dwGAAUF["GADATVON"];
                dwLocal["ABAVAKZ"] = "J";
                dwLocal["ABAWOBST"] = " ";
                dwLocal["ABARESMG"] = qty;
                dwLocal["ABASANZSTK"] = "1";
                dwLocal["ABASSTKGEW"] =qty;
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "INSERT INTO ABAUFM(ABAMANDANT, ABAAUFTYP, ABAAUFKRS, ABAAUFLFD, ABAAUFPOS, ABAAPOS, ABAERLKZ, ABARESMG, ABASANZSTK, ABASSTKLG, ABASSTKLGV, ABASSTKLGB, ABASSTKGEW, ABASSTKGEWV, ABASSTKGEWB, ABASSTKBRT, ABASSTKBRTV, ABASSTKBRTB, ABAIANZSTK, ABAIZENSUR1, ABAIZENSURKZ1, ABAIZENSUR2, ABAIZENSURKZ2, ABAIGESLGZS1, ABAIGESLGZS2, ABASTDPOS, ABASFERTKZ, ABAUEBKZ, ABAUMAILKZ, ABASGESLG, ABASGESGEW, ABASME, ABAFRMG, ABARSTSLG, ABARSTSGEW, ABAMINUSLG, ABAMINUSGEW, ABALEAPOS, ABAPOOL, ABARESFLAG, ABAVKAUFTYP, ABAVKAUFKRS, ABAVKAUFLFD, ABAVKAUFPOS, ABAVKUPOS, ABAVB, ABAVG, ABAZUPRIO, ABASTKNEUTR, ABARESPROG, ABARESBEN, ABARESDAT, ABARESZEIT, ABARVSACHB, ABARKUNDNR, ABARBISDAT, ABAVLVB, ABAVLVG, ABAVLSACHB, ABAVLGEGEN, ABAPRKUNDNR, ABAPRAUFKRS, ABAPRAUFLFD, ABAPRAUFPOS, ABAGENEHM, ABAGSACHB, ABALIEFNR, ABAVSACHB, ABAVSTKNR, ABAVERSWEG, ABAMVERSDAT, ABAWVDAT, ABGENDAT, ABAGENNR, ABAGENNAME, ABAGENWEG, ABAZUSTK, ABAZULG, ABAOPTKZ, ABAMAFZST, ABAPART1, ABAPARTST1, ABAPART2, ABAPARTST2, ABAPART3, ABAPARTST3, ABAPART4, ABAPARTST4, ABAPART5, ABAPARTST5, ABAPART6, ABAPARTST6, ABAPART7, ABAPARTST7, ABAPART8, ABAPARTST8, ABAPART9, ABAPARTST9, ABAPART10, ABAPARTST10, ABASZENSUR, ABASZENSURKZ, ABAKUTLSTK, ABABAHNKZ, ABAWDUPOS, ABABAHNEN, ABATEILKZ, ABAKUNDNRU, ABAWERKU, ABAABTU, ABAARTU, ABAVARU, ABADESSU, ABACOLORITU, ABAFARBEU, ABABESCHU, ABAFARBBEZU, ABAANZ1, ABALAENGE1, ABABREITE1, ABAANZ2, ABALAENGE2, ABABREITE2, ABAANZ3, ABALAENGE3, ABABREITE3, ABAANZ4, ABALAENGE4, ABABREITE4, ABAANZ5, ABALAENGE5, ABABREITE5, ABAVERSDAT, ABAVATYP, ABAANZORG, ABAANZKOP, ABAVERSART, ABASPED, ABALIEFKD, ABAVERSKD, ABAADRSLL, ABAVAKZ, ABALIEFKOMP, ABATEILNR, ABAVDPKZ, ABATPMA, ABABOXMAX, ABABOXANZ, ABALGEBNR, ABANKGEB, ABAIFEUCHTE, ABAKUNDNR, ABASTKNR, ABAPARTIE, ABAPARTIEKZ, ABAKDPARTIE, ABAKDAUFTNR, ABAKDAUFDAT, ABAMAART, ABASTKLFDNR, ABAAUFMSL, ABAZUSAM, ABAPACKTYP, ABATAX, ABAHUELSE, ABAWOBST, ABAWICKL, ABAFDRES, ABAKF, ABANRVERG, ABASTKNRKRS, ABASUFFART, ABATRENNZ, ABALAENGEU, ABALAENGES, ABASCHRITW, ABAFUELLZ, ABAASSCHNIT, ABAETITYP, ABAANZRET, ABAKDETKZ, ABADOPPEL, ABALOAN, ABALBAN, ABALPAN, ABAAUFBKZAN, ABALOA2, ABALBA2, ABALPA2, ABAABKZA2, ABAPKL, ABABEM1, ABABEM2, ABAMRKM1, ABAMRKM2, ABAMRKM3, ABAKZNTO, ABAFESP, ABADIAUFKRS, ABADIAUFLFD, ABADIAUFPOS, ABADILG, ABADIGEW, ABADISTK, ABADISLG, ABADISGEW, ABABA, ABAASGESLG, ABAASGESGEW, ABAPNRKRS, ABAPLFDNR, ABAGKREGEL, ABAPROVOR, ABAPRSFE, ABAWSCHTXT, ABAVORSGEL, ABASELVL, ABASELVR, ABAKOLL, ABAVKART, ABAVKFARBE, ABAGBEDKZ, ABADL, ABAKDPARTKZ, ABAFILLER, ABAAENDZL, ABAAENDBEN, ABAAENDDAT, ABANEUBEN, ABANEUDAT)"
                    + "VALUES (:ABAMANDANT, :ABAAUFTYP, :ABAAUFKRS, :ABAAUFLFD, :ABAAUFPOS,'0002', ' ', 0"
                + ", 0, 0, 100, 9999000, 0, 0, 0, 0, 0, 0, 0, ' ', ' ', ' ', ' ', 0, 0, 1, ' ', ' ', ' ', 0, 0, ' ', 0, 0, 0, 0, 0, 0, ' ', ' '"
                + ", ' ', '  ', '      ', '   ', '  ', '   ', '   ', '7', ' ', '        ', '        ', 0, 0, '        ', '        ', 0, '   ', '   ', '        ', ' ', '        '"
                + ", '  ', '      ', '   ', ' ', '        ', '        ', '        ', '            ', '  ', 0, 0, 0, '            ', '                              ', '  ', 0, 0, ' ', 0, '           ', 0, '           ', 0, '           ', 0"
                + ", '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, '           ', 0, ' ', ' ', 0, ' ', 1, 0, ' ', '        ', '   ', '   ', '                    ', '   ', '          ', '          '"
                + ", '          ', '          ', '                    ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '  ', 0, 0, '   ', '   ', '        ', '        ', '        ', ' ', ' ', 0, ' ', '    ', 0, 0, '        ', '  ', 0, '00000000'"
                + ", '            ', '0000000', ' ', '          ', '                    ', 0, ' ', 0, '  ', '  ', '    ', '   ', '      ', 'I', ' ', ' ', ' ', ' ', '  ', ' ', ' ', 0, 0, 0, ' ', ' ', '  ', 0, ' ', '          ', '  ', '  ', '        ', ' ', '  ', '  ', '        ', ' '"
                + ", '  ', '                                                            ', '                                                            ', '    ', '    ', '    ', ' ', ' ', '  ', '000000', '000', 0, 0, 0, 0, 0, '      ', 0, 0, '  ', '000000'"
                + ", '00000000', '        ', 0, '   ', ' ', 0, 0, '     ', '                        ', '          ', ' ', ' ', ' ', '                                                                                    ', 0, '        ', 0"
                + ", :ABANEUBEN, :ABANEUDAT)";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABANEUBEN", OracleType.NVarChar).Value = dwLocal["ABANEUBEN"];
                or1.Parameters.Add("ABANEUDAT", OracleType.NVarChar).Value = dwLocal["ABANEUDAT"];
                setResult = Connect2Proxy(or1);


                #region============UPDATE0002====================== 
                 /*
                or1 = OracleDB.CreateCommand(); 
                or1.CommandText = "UPDATE ABAUFM SET "
                    + "ABAVKAUFKRS=:ABAVKAUFKRS,ABAVKAUFLFD=:ABAVKAUFLFD,ABAVKAUFPOS=:ABAVKAUFPOS,ABAVKUPOS=:ABAVKUPOS"
                //+",ABAPRAUFKRS=:ABAPRAUFKRS,ABAPRAUFLFD=:ABAPRAUFLFD,ABAPRAUFPOS=:ABAPRAUFPOS,ABAVERSDAT=:ABAVERSDAT "
                   // + ",ABAVAKZ=:ABAVAKZ,ABAWOBST=:ABAWOBST,ABARESMG=:ABARESMG,ABASANZSTK=:ABASANZSTK,ABASSTKGEW=:ABASSTKGEW"
                + " WHERE ABAMANDANT=:ABAMANDANT AND ABAAUFTYP=:ABAAUFTYP AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS AND ABAAPOS=:ABAAPOS";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABAAPOS", OracleType.NVarChar).Value = dwLocal["ABAAPOS"];

                or1.Parameters.Add("ABAVKAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAVKAUFTYP"];
                or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAVKAUFKRS"];
                or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAVKAUFLFD"];
                or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAVKAUFPOS"];
                or1.Parameters.Add("ABAVKUPOS", OracleType.NVarChar).Value = dwLocal["ABAVKUPOS"];

              or1.Parameters.Add("ABAPRAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAPRAUFKRS"];
                or1.Parameters.Add("ABAPRAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAPRAUFLFD"];
                or1.Parameters.Add("ABAPRAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAPRAUFPOS"];
                or1.Parameters.Add("ABAVERSDAT", OracleType.NVarChar).Value = dwLocal["ABAVERSDAT"];
                or1.Parameters.Add("ABAVAKZ", OracleType.NVarChar).Value = dwLocal["ABAVAKZ"];
                or1.Parameters.Add("ABAWOBST", OracleType.NVarChar).Value = dwLocal["ABAWOBST"];
                or1.Parameters.Add("ABARESMG", OracleType.NVarChar).Value = dwLocal["ABARESMG"];
                or1.Parameters.Add("ABASANZSTK", OracleType.NVarChar).Value = dwLocal["ABASANZSTK"];

                or1.Parameters.Add("ABASSTKGEW", OracleType.NVarChar).Value = dwLocal["ABASSTKGEW"];
                */
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE ABAUFM SET "
                    + " ABASSTKLG=:ABASSTKLG,ABAVKAUFTYP=:ABAVKAUFTYP,ABAVKAUFKRS=:ABAVKAUFKRS,ABAVKAUFLFD=:ABAVKAUFLFD,ABAVKAUFPOS=:ABAVKAUFPOS "
                    + ",ABAVKUPOS=:ABAVKUPOS,ABAVB=:ABAVB,ABAVLSACHB=:ABAVLSACHB,ABAPRKUNDNR=:ABAPRKUNDNR,ABAPRAUFKRS=:ABAPRAUFKRS,ABAPRAUFLFD=:ABAPRAUFLFD,ABAPRAUFPOS=:ABAPRAUFPOS,ABAVERSDAT=:ABAVERSDAT"
                    + ",ABARVSACHB=:ABARVSACHB,ABARKUNDNR=:ABARKUNDNR,ABAVLVB=:ABAVLVB"
                    + ",ABARESMG=:ABARESMG,ABASANZSTK=:ABASANZSTK,ABASSTKGEW=:ABASSTKGEW"
                + " WHERE ABAMANDANT=:ABAMANDANT AND ABAAUFTYP=:ABAAUFTYP AND ABAAUFKRS=:ABAAUFKRS AND ABAAUFLFD=:ABAAUFLFD AND ABAAUFPOS=:ABAAUFPOS AND ABAAPOS=:ABAAPOS";
                or1.Parameters.Add("ABAMANDANT", OracleType.NVarChar).Value = dwLocal["ABAMANDANT"];
                or1.Parameters.Add("ABAAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAAUFTYP"];
                or1.Parameters.Add("ABAAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAAUFKRS"];
                or1.Parameters.Add("ABAAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAAUFLFD"];
                or1.Parameters.Add("ABAAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAAUFPOS"];
                or1.Parameters.Add("ABAAPOS", OracleType.NVarChar).Value = "0002"; 

                or1.Parameters.Add("ABASSTKLG", OracleType.NVarChar).Value = dwLocal["ABASSTKLG"];

                or1.Parameters.Add("ABAVKAUFTYP", OracleType.NVarChar).Value = dwLocal["ABAVKAUFTYP"];
                or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAVKAUFKRS"];
                or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAVKAUFLFD"];
                or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAVKAUFPOS"];
                or1.Parameters.Add("ABAVKUPOS", OracleType.NVarChar).Value = dwLocal["ABAVKUPOS"];
                or1.Parameters.Add("ABAVB", OracleType.NVarChar).Value = dwLocal["ABAVB"];
                or1.Parameters.Add("ABAVLSACHB", OracleType.NVarChar).Value = dwLocal["ABAVLSACHB"];
                or1.Parameters.Add("ABAPRKUNDNR", OracleType.NVarChar).Value = dwLocal["ABAPRKUNDNR"];
                or1.Parameters.Add("ABAVLVB", OracleType.NVarChar).Value = dwLocal["ABAVLVB"];

                or1.Parameters.Add("ABARVSACHB", OracleType.NVarChar).Value = dwLocal["ABARVSACHB"];
                or1.Parameters.Add("ABARKUNDNR", OracleType.NVarChar).Value = dwLocal["ABARKUNDNR"];

                or1.Parameters.Add("ABAPRAUFKRS", OracleType.NVarChar).Value = dwLocal["ABAPRAUFKRS"];
                or1.Parameters.Add("ABAPRAUFLFD", OracleType.NVarChar).Value = dwLocal["ABAPRAUFLFD"];
                or1.Parameters.Add("ABAPRAUFPOS", OracleType.NVarChar).Value = dwLocal["ABAPRAUFPOS"];
                or1.Parameters.Add("ABAVERSDAT", OracleType.NVarChar).Value = dwLocal["ABAVERSDAT"];
                
                or1.Parameters.Add("ABARESMG", OracleType.NVarChar).Value = dwLocal["ABARESMG"];
                or1.Parameters.Add("ABASANZSTK", OracleType.NVarChar).Value = dwLocal["ABASANZSTK"];
                or1.Parameters.Add("ABASSTKGEW", OracleType.NVarChar).Value = dwLocal["ABASSTKGEW"];
       
                setResult = Connect2Proxy(or1);
                #endregion
                #endregion 
         
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
        public DataSet InsertAB50GAAUF(DataRow dwAB50, string abplo, string abplb, string abplp)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            OracleCommand or1;
            DataRow dwLocal = null, dwGSDAT = null;
            try
            {
               
                string ART = "", VAR = "", FARBE = "";
                ART = dwAB50["ABPART"].ToString();
                VAR = dwAB50["ABPVAR"].ToString();
                FARBE = dwAB50["ABPFARBE"].ToString();
                setResult = QueryGASTGA(ART, VAR, FARBE);
                setReturn.Merge(setResult); 
                double meterpkg = 0;
                if (setResult.Tables["GASTGA"].Rows.Count == 0)
                    return setReturn;
                foreach (DataRow dwGASTGA in setResult.Tables["GASTGA"].Rows)
                {
                    
                    #region============MAPDATA=========================
                    dwLocal = SetData.GAAUF.NewGAAUFRow();
                    dwLocal["GAMANDANT"] = dwAB50["ABPMANDANT"];
                    dwLocal["GAAUFKRS"] = dwAB50["ABPAUFKRS"];
                    dwLocal["GAAUFLFD"] = dwAB50["ABPAUFLFD"];
                    dwLocal["GAAUFPOS"] = dwAB50["ABPAUFPOS"];
                    dwLocal["GANEUBEN"] = dwAB50["ABPNEUBEN"];
                    dwLocal["GANEUDAT"] = dwAB50["ABPNEUDAT"];
                    dwLocal["GABEM"] = Left(DISPONUM + "                                                                    ", 40);
                    #endregion

                    #region============INSERT 001==========================
                    or1 = OracleDB.CreateCommand();
                    dwLocal["GAPOS"] = dwGASTGA["GAGPOS"];
                    or1.CommandText = "INSERT INTO GAAUF(GAMANDANT, GAAUFKRS, GAAUFLFD, GAAUFPOS, GASA, GAPOS, GAAENDZL, GAAENDBEN, GAAENDDAT, GANEUBEN, GANEUDAT, GADATVON, GADATBIS, GADATVON1, GADATBIS1, GAART, GAVAR, GAFARBE, GAURVAR, GADEZI, GAKG1, GASP1, GAKA1, GAKG2, GASP2, GAKA2, GAKG3, GASP3, GAKA3, GAKG4, GASP4, GAKA4, GAKG5, GASP5, GAKA5, GAKG6, GASP6, GAKA6, GAKG7, GASP7, GAKA7, GAABF, GAERLKZ, GADISPOKZ, GALO, GALB, GALP, GAAUFBKZ, GABEM, GAVPEINH, GAHUELSE, GAANZBAUM, GASPUL, GALAENGE, GASPULGEW, GAAG, GAPRODV, GAAUFMSL, GAKF, GAFDRES, GAWICKL, GASACHB, GAANLO, GAANLB, GAANLP, GAANAUFBKZ, GALIEFSCH, GAFREIDAT, GAFREIBEN, GALIEFNR, GAMATKOMPDR, GAFUSSTEXT, GAAFOLGE, GAAUFTRKZ, GABDEKZ, GABASMG2, GABRUTTOKZ, GAERSATZ, GAURSA, GAURPOS, GATLSA, GATLPOS, GAINFOKZ, GADECKUNG, GAUSERZK, GAVARKZ, GAZUKOMP, GAAFDLGS, GAAFDLGSZ, GAGESFDZ, GABEDFDZ, GAZLLG, GAABF2, GAZBEDKG, GAFILLER)"
                        + "VALUES (:GAMANDANT, :GAAUFKRS, :GAAUFLFD, :GAAUFPOS, '713', :GAPOS, 1, '        ', '00000000', :GANEUBEN, :GANEUDAT, 0, 0, '        ', '        '"
                        + ", '                    ', '   ', '          ', '   ', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'B', 'EX', 'WV', '010101  ', ' ', :GABEM, '    ', '      ', '00', 1, 6430499, 0, '  ', '  ', '  ', ' ', ' ', ' ', '        ', '  ', '  ', '        ', ' ', '        ', 0, '        ', '        ', ' ', '   ', '050', 'K', ' ', 3841, ' ', ' ', '   ', '00', '   ', '00', ' ', ' ', '        ', ' ', ' ', 0, 0, 0, 0, 0, 0, 0, '                                         ')";
                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwLocal["GAMANDANT"];
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwLocal["GAAUFKRS"];
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwLocal["GAAUFLFD"];
                    or1.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwLocal["GAAUFPOS"];
                    or1.Parameters.Add("GAPOS", OracleType.NVarChar).Value = dwLocal["GAPOS"];
                    or1.Parameters.Add("GABEM", OracleType.NVarChar).Value = dwLocal["GABEM"];
                    or1.Parameters.Add("GANEUBEN", OracleType.NVarChar).Value = dwLocal["GANEUBEN"];
                    or1.Parameters.Add("GANEUDAT", OracleType.NVarChar).Value = dwLocal["GANEUDAT"]; 
                    setResult = Connect2Proxy(or1);
                    dwLocal["GADATVON"] = dwAB50["ABPSTARTDAT"];
                    dwLocal["GADATBIS"] = dwAB50["ABPSTARTDAT"];
                    dwLocal["GAART"] = dwGASTGA["GAGGART"];
                    dwLocal["GAVAR"] = dwGASTGA["GAGGVAR"];
                    dwLocal["GAFARBE"] = dwGASTGA["GAGGFARBE"];
                    double qty = System.Convert.ToDouble(dwAB50["ABPSOLLMENGE5"]);
                    double RT = System.Convert.ToDouble(dwGASTGA["GAGKGBRUT"]);
                    double GAKG1 = System.Math.Round(qty *RT*0.00001 * 0.01, 0); 
                    dwLocal["GAKG1"] = GAKG1;
                    dwLocal["GABASMG2"] = dwGASTGA["GAGBASIS"];
                    dwLocal["GALO"] = abplo;
                    dwLocal["GALB"] = abplb;
                    dwLocal["GALP"] = abplb;
                    dwLocal["GADISPOKZ"] = dwGASTGA["GAGDISPOKZ"];
                    dwLocal["GASPUL"] = 1;
                    dwLocal["GALAENGE"] = 0;// System.Math.Round(meterpkg * GAKG1, 0);
                    or1 = OracleDB.CreateCommand();
                    or1.CommandText = "UPDATE GAAUF SET GADATVON=:GADATVON "
                        + ",GADATBIS=:GADATBIS,GAART=:GAART,GAVAR=:GAVAR,GAFARBE=:GAFARBE,GAKG1=:GAKG1"
                        + ",GABASMG2=:GABASMG2,GALO=:GALO,GALB=:GALB,GALP=:GALP,GADISPOKZ=:GADISPOKZ"
                        + ",GASPUL=:GASPUL,GALAENGE=:GALAENGE"
                        + " WHERE GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD AND GAAUFPOS=:GAAUFPOS AND GAPOS=:GAPOS";

                    or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwLocal["GAMANDANT"];
                    or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwLocal["GAAUFKRS"];
                    or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwLocal["GAAUFLFD"];
                    or1.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwLocal["GAAUFPOS"];
                    or1.Parameters.Add("GAPOS", OracleType.NVarChar).Value = dwLocal["GAPOS"];

                    or1.Parameters.Add("GADATVON", OracleType.NVarChar).Value = dwLocal["GADATVON"];
                    or1.Parameters.Add("GADATBIS", OracleType.NVarChar).Value = dwLocal["GADATBIS"];
                    or1.Parameters.Add("GAART", OracleType.NVarChar).Value = dwLocal["GAART"];
                    or1.Parameters.Add("GAVAR", OracleType.NVarChar).Value = dwLocal["GAVAR"];
                    or1.Parameters.Add("GAFARBE", OracleType.NVarChar).Value = dwLocal["GAFARBE"];
                    or1.Parameters.Add("GAKG1", OracleType.NVarChar).Value = dwLocal["GAKG1"];
                    or1.Parameters.Add("GABASMG2", OracleType.NVarChar).Value = dwLocal["GABASMG2"];
                    or1.Parameters.Add("GALO", OracleType.NVarChar).Value = dwLocal["GALO"];
                    or1.Parameters.Add("GALB", OracleType.NVarChar).Value = dwLocal["GALB"];
                    or1.Parameters.Add("GALP", OracleType.NVarChar).Value = dwLocal["GALP"];
                    or1.Parameters.Add("GADISPOKZ", OracleType.NVarChar).Value = dwLocal["GADISPOKZ"];

                    or1.Parameters.Add("GASPUL", OracleType.NVarChar).Value = dwLocal["GASPUL"];
                    or1.Parameters.Add("GALAENGE", OracleType.NVarChar).Value = dwLocal["GALAENGE"];
                    setResult = Connect2Proxy(or1);
                    #endregion
                 
                }
                #region============INSERT 002==========================

                or1 = OracleDB.CreateCommand();
                dwLocal["GAPOS"] = "00";
                or1.CommandText = "INSERT INTO GAAUF(GAMANDANT, GAAUFKRS, GAAUFLFD, GAAUFPOS, GASA, GAPOS, GAAENDZL, GAAENDBEN, GAAENDDAT, GANEUBEN, GANEUDAT, GADATVON, GADATBIS, GADATVON1, GADATBIS1, GAART, GAVAR, GAFARBE, GAURVAR, GADEZI, GAKG1, GASP1, GAKA1, GAKG2, GASP2, GAKA2, GAKG3, GASP3, GAKA3, GAKG4, GASP4, GAKA4, GAKG5, GASP5, GAKA5, GAKG6, GASP6, GAKA6, GAKG7, GASP7, GAKA7, GAABF, GAERLKZ, GADISPOKZ, GALO, GALB, GALP, GAAUFBKZ, GABEM, GAVPEINH, GAHUELSE, GAANZBAUM, GASPUL, GALAENGE, GASPULGEW, GAAG, GAPRODV, GAAUFMSL, GAKF, GAFDRES, GAWICKL, GASACHB, GAANLO, GAANLB, GAANLP, GAANAUFBKZ, GALIEFSCH, GAFREIDAT, GAFREIBEN, GALIEFNR, GAMATKOMPDR, GAFUSSTEXT, GAAFOLGE, GAAUFTRKZ, GABDEKZ, GABASMG2, GABRUTTOKZ, GAERSATZ, GAURSA, GAURPOS, GATLSA, GATLPOS, GAINFOKZ, GADECKUNG, GAUSERZK, GAVARKZ, GAZUKOMP, GAAFDLGS, GAAFDLGSZ, GAGESFDZ, GABEDFDZ, GAZLLG, GAABF2, GAZBEDKG, GAFILLER)"
                    + "VALUES (:GAMANDANT, :GAAUFKRS, :GAAUFLFD, :GAAUFPOS, '310', :GAPOS, 1, '        ', '00000000', :GANEUBEN, :GANEUDAT, 0, 0, '        ', '        '"
                    + ", '                    ', '   ', '          ', '   ', ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ' ', 'B', 'EX', 'WV', '010101  ', ' ', :GABEM, '    ', '      ', '00', 1, 6430499, 0, '  ', '  ', '  ', ' ', ' ', ' ', '        ', '  ', '  ', '        ', ' ', '        ', 0, '        ', '        ', ' ', '   ', '050', 'K', ' ', 3841, ' ', ' ', '   ', '00', '   ', '00', ' ', ' ', '        ', ' ', ' ', 0, 0, 0, 0, 0, 0, 0, '                                         ')";
                or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwLocal["GAMANDANT"];
                or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwLocal["GAAUFKRS"];
                or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwLocal["GAAUFLFD"];
                or1.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwLocal["GAAUFPOS"];
                or1.Parameters.Add("GAPOS", OracleType.NVarChar).Value = dwLocal["GAPOS"];
                or1.Parameters.Add("GABEM", OracleType.NVarChar).Value = dwLocal["GABEM"];
                or1.Parameters.Add("GANEUBEN", OracleType.NVarChar).Value = dwLocal["GANEUBEN"];
                or1.Parameters.Add("GANEUDAT", OracleType.NVarChar).Value = dwLocal["GANEUDAT"];
                setResult = Connect2Proxy(or1);
                dwLocal["GADATVON"] = dwAB50["ABPSTARTDAT"];
                dwLocal["GADATBIS"] = dwAB50["ABPSTARTDAT"];
                dwLocal["GAART"] = dwAB50["ABPART"];
                dwLocal["GAVAR"] = dwAB50["ABPVAR"];
                dwLocal["GAFARBE"] = dwAB50["ABPFARBE"];
                dwLocal["GAKG1"] = dwAB50["ABPSOLLMENGE5"];
                dwLocal["GAKG2"] = dwAB50["ABPSOLLMENGE5"];
                dwLocal["GABASMG2"] = 0;
                dwLocal["GALO"] = abplo;
                dwLocal["GALB"] = abplb;
                dwLocal["GALP"] = abplb;
                dwLocal["GADISPOKZ"] = " ";
                dwLocal["GASPUL"] = 1;
                dwLocal["GALAENGE"] = 0;// System.Math.Round(meterpkg * GAKG1, 0);
                or1 = OracleDB.CreateCommand();
                or1.CommandText = "UPDATE GAAUF SET GADATVON=:GADATVON "
                    + ",GADATBIS=:GADATBIS,GAART=:GAART,GAVAR=:GAVAR,GAFARBE=:GAFARBE,GAKG1=:GAKG1"
                    + ",GABASMG2=:GABASMG2,GALO=:GALO,GALB=:GALB,GALP=:GALP,GADISPOKZ=:GADISPOKZ"
                    + ",GASPUL=:GASPUL,GALAENGE=:GALAENGE"
                    + " WHERE GAMANDANT=:GAMANDANT AND GAAUFKRS=:GAAUFKRS AND GAAUFLFD=:GAAUFLFD AND GAAUFPOS=:GAAUFPOS AND GAPOS=:GAPOS";

                or1.Parameters.Add("GAMANDANT", OracleType.NVarChar).Value = dwLocal["GAMANDANT"];
                or1.Parameters.Add("GAAUFKRS", OracleType.NVarChar).Value = dwLocal["GAAUFKRS"];
                or1.Parameters.Add("GAAUFLFD", OracleType.NVarChar).Value = dwLocal["GAAUFLFD"];
                or1.Parameters.Add("GAAUFPOS", OracleType.NVarChar).Value = dwLocal["GAAUFPOS"];
                or1.Parameters.Add("GAPOS", OracleType.NVarChar).Value = dwLocal["GAPOS"];

                or1.Parameters.Add("GADATVON", OracleType.NVarChar).Value = dwLocal["GADATVON"];
                or1.Parameters.Add("GADATBIS", OracleType.NVarChar).Value = dwLocal["GADATBIS"];
                or1.Parameters.Add("GAART", OracleType.NVarChar).Value = dwLocal["GAART"];
                or1.Parameters.Add("GAVAR", OracleType.NVarChar).Value = dwLocal["GAVAR"];
                or1.Parameters.Add("GAFARBE", OracleType.NVarChar).Value = dwLocal["GAFARBE"];
                or1.Parameters.Add("GAKG1", OracleType.NVarChar).Value = dwLocal["GAKG1"];
                or1.Parameters.Add("GAKG2", OracleType.NVarChar).Value = dwLocal["GAKG2"];
                or1.Parameters.Add("GALO", OracleType.NVarChar).Value = dwLocal["GALO"];
                or1.Parameters.Add("GALB", OracleType.NVarChar).Value = dwLocal["GALB"];
                or1.Parameters.Add("GALP", OracleType.NVarChar).Value = dwLocal["GALP"];
                or1.Parameters.Add("GADISPOKZ", OracleType.NVarChar).Value = dwLocal["GADISPOKZ"];

                or1.Parameters.Add("GASPUL", OracleType.NVarChar).Value = dwLocal["GASPUL"];
                or1.Parameters.Add("GALAENGE", OracleType.NVarChar).Value = dwLocal["GALAENGE"];
                setResult = Connect2Proxy(or1);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        } 
        public DataSet ExecuteInsertAB50(DataRow dwGAAUF, string ABKAUFART)
        {
            DataSet setReturn = new DataSet();
            DataSet setResult = new DataSet();
            DataRow dwAB50 = null;
            try
            {
                string KRS = "T5";
                DataRow dwFlow = null;
                string stage = "R", art = "", var = "", color = "", matchid = "", finish = "";
                string abplo = "01", abplb = "01", abplp = "010101";
                int LeadTime = 3;
                string sKRS = "", sLFD = "", sPOS = "";
                string apKRS, apNum;
                stage = "Y";
                art = dwGAAUF["GAART"].ToString();
                var = dwGAAUF["GAVAR"].ToString();
                color = dwGAAUF["GAFARBE"].ToString();
                matchid = "YD";
                dwFlow = GetProcessFlow(stage, art, var, color, matchid);
                if (dwFlow == null)
                    return setReturn;
                KRS = dwFlow["ABKKRS"].ToString();
                sKRS = dwFlow["ABKRS"].ToString();
                sLFD = dwFlow["ABLFD"].ToString();
                sPOS = dwFlow["ABPOS"].ToString();
                apKRS = dwFlow["APKRS"].ToString();
                apNum = dwFlow["APNR"].ToString();
                LeadTime = System.Convert.ToInt16(dwFlow["LEADTIME"].ToString());
                abplo = dwFlow["ABLO"].ToString();
                abplb = dwFlow["ABLB"].ToString();
                abplp = dwFlow["ABLP"].ToString();
                #region============ABPOS======================
                EventDispatcher.Instance.RaiseStatus("开始创建染纱ABPOS", StatusEventType.RunningProgress);
                setResult = InsertAB50ABPOS(dwGAAUF, ABKAUFART, KRS, LeadTime,apKRS,apNum,abplo,abplb,abplb);
                #endregion
                if (!setResult.Tables.Contains("ABPOS"))
                    return setReturn;
                if (setResult.Tables["ABPOS"].Rows.Count == 0)
                {
                    return setReturn;
                }
                dwAB50 = setResult.Tables["ABPOS"].Rows[0];
                setReturn.Merge(setResult);
                #region============ABKOPF=====================
                EventDispatcher.Instance.RaiseStatus("开始创建染纱ABKOPF", StatusEventType.RunningProgress);
                setResult = InsertABKOPF(dwAB50, ABKAUFART);
                setReturn.Merge(setResult);
                #endregion

                #region============ABPR=======================
                EventDispatcher.Instance.RaiseStatus("开始创建染纱ABPR", StatusEventType.RunningProgress);
                setResult = InsertABPR(dwAB50);
                setReturn.Merge(setResult);
                #endregion

                #region============ABFOLGE====================
                EventDispatcher.Instance.RaiseStatus("开始创建染纱ABFOLGE", StatusEventType.RunningProgress);
                setResult = InsertABFOLGE(dwAB50, sKRS,sLFD,sPOS);
                setReturn.Merge(setResult);
                #endregion

                #region============ABAUFM=====================
                EventDispatcher.Instance.RaiseStatus("开始创建染纱ABAUFM", StatusEventType.RunningProgress);
                setResult = InsertAB50ABAUFM(dwAB50, dwGAAUF);
                setReturn.Merge(setResult); 
                #endregion 
 
                #region============GAAUF=====================
                EventDispatcher.Instance.RaiseStatus("开始创建染纱GAAUF", StatusEventType.RunningProgress);
                setResult = InsertAB50GAAUF(dwAB50,abplo,abplb,abplp);
                setReturn.Merge(setResult);
                #endregion
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }

    }
}
